#同步多个微信群消息
#本项目基于itchat https://github.com/littlecodersh/itchat
#打包exe pyinstaller -F main.py

import itchat
from itchat.content import *

# print(itchat.get_chatrooms())

def lc():
    print('登录。。')
def ec():
    print('退出。。')

itchat.auto_login(enableCmdQR=True, hotReload=False)
itchat.get_chatrooms(True)

qun1Name = '1👫西平郑州顺风群 (禁发无关信息)'
qun2Name = '2👫西平郑州顺风群 (禁发无关信息)'
qun3Name = '3👫西平郑州顺风群 (禁发无关信息)'

qun1 = itchat.search_chatrooms(name=qun1Name)[0]
qun2 = itchat.search_chatrooms(name=qun2Name)[0]
qun3 = itchat.search_chatrooms(name=qun3Name)[0]


# @itchat.msg_register(TEXT)
# def text_reply(msg):
    # msg.user.send('%s: %s' % (msg.type, msg.text))
    # print("[转] %s" % msg.text)

@itchat.msg_register(TEXT, isGroupChat=True)
def pinche_group_reply(msg):
    text = msg.text.strip()
    # print('%s: %s' % (msg.user.NickName, msg.text))
    if(msg.user.NickName == qun1Name):
        if(text.startswith("人找车") | text.startswith("车找人") | text.startswith("公告")):
            # qun2.send("[转] %s" % msg.text)
            # qun3.send("[转] %s" % msg.text)
            print("[转] %s" % msg.text)
    elif (msg.user.NickName == qun2Name):
        if(text.startswith("人找车") | text.startswith("车找人") | text.startswith("公告")):
            # qun1.send("[转] %s" % msg.text)
            # qun3.send("[转] %s" % msg.text)
            print("[转] %s" % msg.text)
    elif (msg.user.NickName == qun3Name):
        if(text.startswith("人找车") | text.startswith("车找人") | text.startswith("公告")):
            # qun1.send("[转] %s" % msg.text)
            # qun2.send("[转] %s" % msg.text)
            print("[转] %s" % msg.text)

itchat.run(True)


